package com.itheima.project.vo;

import org.springframework.security.crypto.bcrypt.BCrypt;
import org.springframework.util.DigestUtils;

public class PswdTest {

    public static void main(String[] args) {

        //md5加密
        String md5Pswd1 = DigestUtils.md5DigestAsHex("123456".getBytes());
        String md5Pswd2 = DigestUtils.md5DigestAsHex("123456".getBytes());
        System.out.println(md5Pswd1);
        System.out.println(md5Pswd2);
        System.out.println(md5Pswd1.equals(md5Pswd2));

        System.out.println("-------------------------------------");

        String password1 = BCrypt.hashpw("123456", BCrypt.gensalt());
        String password2 = BCrypt.hashpw("123456", BCrypt.gensalt());
        System.out.println(password1);
        System.out.println(password2);
        System.out.println(password1.equals(password2));
        //校验密码
        boolean checkpw = BCrypt.checkpw("123456", "$2a$10$c8v1RU3boVDYmM2o3VItp.JKfz0d7E.7RaglPmJtYN6HvNIvrqji2");
        System.out.println(checkpw);
    }
}